package org.steven.crm.app.api.processor;

import com.steven.validate.IntegerValidator;
import com.steven.validate.PriceValidator;
import com.steven.validate.StringValidator;
import com.steven.xweb.web.CheckList;
import org.steven.crm.app.api.processor.base.BaseCURDProcessor;
import org.steven.crm.core.service.BaseService;
import org.steven.crm.core.service.customer.CustomerService;
import org.steven.crm.core.service.product.ProductService;

/**
 * @Author wuzw
 * @Date 2024/6/27 0:19
 * @Version 1.0
 */
public class ProductProcessor extends BaseCURDProcessor {
    private static ProductService service = new ProductService();
    @Override
    protected BaseService getService() {
        return service;
    }

    public boolean saveActionCheck() throws Exception {
        CheckList checkList = getChecklist();
        checkList.addCheckItem(new StringValidator("name", "名称", getStringData("name"), true));
        checkList.addCheckItem(new PriceValidator("price", "价格", getStringData("price"), true));
        checkList.addCheckItem(new IntegerValidator("stock", "库存", getStringData("stock"), true));
        return checkList.check();
    }

    public void readAllAction() throws Exception {
        setObjectData(service.listAll());
    }
}
